import 'package:flutter/material.dart';

import '../pages/tabs.dart';
import '../pages/news.dart';
import '../pages/news-content.dart';
import '../pages/device.dart';
import '../pages/location.dart';
import '../pages/image-picker.dart';
import '../pages/chewie-video.dart';
import '../pages/network.dart';
import '../pages/storage.dart';
import '../pages/scan.dart';
import '../pages/app-version.dart';
import '../pages/url-launcher.dart';
import '../pages/ali-wx-pay.dart';

//配置路由
final routes={
    '/':(context)=> Tabs(), 
    '/news':(context)=> NewsPage(),
    '/newsContent':(context, {arguments})=> NewsContent(arguments:arguments),
    '/devicePage':(context)=> DevicePage(),    
    '/locationPage':(context)=> LocationPage(),  
    '/imagePicker':(context)=> ImagePickerDemo(),  
    '/videoPlayer':(context)=> ChewieVideoDemo(),  
    '/network':(context)=> NetworkDemo(),  
    '/storage':(context)=> StorageDemo(),  
    '/scan':(context)=> ScanPage(),  
    '/appVersion':(context)=> AppVersionPage(),  
    '/urlLauncher':(context)=> UrlLauncherPage(),  
    '/alipay':(context)=> AliPay(),  
};

//固定写法
var onGenerateRoute=(RouteSettings settings) {
      // 统一处理
      final String name = settings.name; 
      final Function pageContentBuilder = routes[name];
      if (pageContentBuilder != null) {
        if (settings.arguments != null) {
          final Route route = MaterialPageRoute(
              builder: (context) =>
                  pageContentBuilder(context, arguments: settings.arguments));
          return route;
        }else{
            final Route route = MaterialPageRoute(
              builder: (context) =>
                  pageContentBuilder(context));
            return route;
        }
      }
};